Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the ability to select list items in the context by index. #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mintchaos
Copy link

This matches the behavior of JS implementations of mustache. Tested
against mustache.js and Hogan.

>>> context = {"data": ['one', 'two', 'three']}
>>> pystache.render("{{ data.0 }}", context)
'one'

Tests added and all previous behavior maintained.

This matches the behavior of JS implementations of mustache. Tested
against mustache.js and Hogan.

>>> context = {"data": ['one', 'two', 'three']}
>>> pystache.render("{{ data.0 }}", context)
'one'
@cjerdonek
Copy link
Collaborator

Is this a duplicate of issue #134?

@mintchaos
Copy link
Author

@cjerdonek I haven't actually tried the syntax in #134, but I'd imagine that this solves that as well.

@godsarmy
Copy link

I think checkin 316c9d4 to support element cherrypick by index with syntax "{{array_key.index}}" is very important feature for this project.

Without this feature, some data could not be rendered from array.

If you try http://mustache.github.io/#demo, you could find that javascript library has already supported this syntax.

@gaastonsr
Copy link

This has not been added yet?

@denisvm
Copy link

denisvm commented Jul 24, 2015

👍

Very important and interesting feature indeed!

@grayb
Copy link

grayb commented Jan 14, 2016

I would like to have this functionality as well.

@amrelhady
Copy link

Hi @cjerdonek can this be merged please?

@JiBB
Copy link

JiBB commented Aug 4, 2016

I too would love to have this merged in. Any chance that this project will be updated ever again?

@llama
Copy link

llama commented Nov 8, 2016

Any reason why this hasn't been merged?

@jeremyjliu
Copy link

@cjerdonek is this repo (and this useful PR that it contains) no longer being maintained?

@jeortizquan
Copy link

I would like this feature as well.

@jeortizquan
Copy link

but also would be nice to access the last element as a function

>>> context = {"data": ['one', 'two', 'three']}
>>> pystache.render("{{ data.first() }}", context)
'one'
>>> pystache.render("{{ data.last() }}", context)
'three'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.